﻿CREATE PROCEDURE [dbo].[usp_select_Reports_Resubmissions_ByService]
(
	@Application		varchar(255)	= null,
   @StartDate			datetime      = '2000/1/1'   
   ,@EndDate			datetime      = '2010/12/31'   
   ,@Debug              bit              = 0
)
AS

SET NOCOUNT ON;

-- Bootstrap
DECLARE @DebugPrefix       varchar(10)
DECLARE @ErrorCode         int

SET @ErrorCode          = 0;
SET @DebugPrefix        = '>>> DEBUG: '


SELECT
	[Application],
	[ServiceName],
	COUNT([Application]) AS AlertCount,
	CONVERT(VARCHAR, [AuditDate], 101) AS AuditDate
FROM	AuditLog
WHERE	AuditDate BETWEEN @StartDate and @EndDate
GROUP BY [Application], [ServiceName], CONVERT(VARCHAR, [AuditDate], 101)
ORDER BY [Application], [ServiceName], CONVERT(VARCHAR, [AuditDate], 101)


SET NOCOUNT OFF;
